#ifndef ACCOUNT_SYSTEM_BANKINGSYSTEM_H
#define ACCOUNT_SYSTEM_BANKINGSYSTEM_H

#include <vector>
#include <memory>
#include <unordered_map>
#include <string>
#include <random>
#include "Customer.h"
#include "Transaction.h"
using namespace std;
class BankingSystem
{
private:
    vector<shared_ptr<Customer>> customers;                      // 客户列表
    unordered_map<string, shared_ptr<Account>> accounts;    // 账户映射表
    vector<shared_ptr<Transaction>> allTransactions;             // 所有交易记录

    // 用于生成账户ID的随机数生成器
    mt19937 rng;

public:
    BankingSystem();

    // 客户管理
    shared_ptr<Customer> registerCustomer(const string &name);
    shared_ptr<Customer> findCustomer(const string &name) const;

    // 账户管理
    shared_ptr<Account> findAccount(const string &accountId) const;
    bool isAccountIdUnique(const string &accountId) const;
    string generateUniqueAccountId(bool isSavings);

    // 交易操作
    bool deposit(const string &accountId, double amount, const string &note = "");
    bool withdraw(const string &accountId, double amount, const string &note = "");
    bool transfer(const string &sourceAccountId, const string &destAccountId,
                  double amount, const string &note = "");
    void recordTransaction(const shared_ptr<Transaction> &transaction);

    // 显示方法
    vector<shared_ptr<Customer>> getAllCustomers() const;
    vector<shared_ptr<Account>> getAllAccounts() const;
    vector<shared_ptr<Account>> getSavingsAccounts() const;
    vector<shared_ptr<Account>> getCheckingAccounts() const;
    vector<shared_ptr<Transaction>> getAllTransactions() const;

    // 报告生成
    void generateTransactionReport(const string &filename) const;

    // 统计信息
    int getTotalCustomerCount() const;
    int getTotalAccountCount() const;
    double getTotalBalance() const;
};

#endif // ACCOUNT_SYSTEM_BANKINGSYSTEM_H